package com.xpffly.design.strategy.common;

import com.xpffly.design.strategy.common.service.Context;
import com.xpffly.design.strategy.common.service.Strategy;
import com.xpffly.design.strategy.common.service.impl.StrategyImpl1;
import com.xpffly.design.strategy.common.service.impl.StrategyImpl2;

/**
 * @Author: xpengfei
 * @Date: 2021/4/9 21:45
 * @Description：策略模式通用代码场景类
 */
public class Scene {
    public static void main(String[] args) {
        // 声明一个具体的策略
        Strategy strategy = new StrategyImpl1();
        // 声明上下文对象
        Context context = new Context(strategy);
        // 执行封装后的方法
        context.doAnything();
        // 二次封装
        context = new Context(new StrategyImpl2());
        context.doAnything();
    }
}
